import request from '@/utils/request'

// query group list
export function sysGroupSelect(params) {
  return request({
    url: '/online/management/admin/sysgroup/select', params,
    method: 'GET'
  })
}

// query group details according to groupId
export function groupDetails(groupId) {
  return request({
    url: `/online/management/admin/sysgroup/${groupId}`,
    method: 'GET'
  })
}

// create group
export function addGroup(data) {
  return request({
    url: `/online/management/admin/sysgroup/`, data,
    method: 'POST'
  })
}

// modify group
export function updateGroup(groupId, data) {
  return request({
    url: `/online/management/admin/sysgroup/${groupId}`, data,
    method: 'POST'
  })
}

// delete Group
export function deleteGroup(groupId) {
  return request({
    url: `/online/management/admin/sysgroup/${groupId}`,
    method: 'DELETE'
  })
}

// 获取指定分组下的app（添加应用前，需要先返回该分组下的全部应用及未属于该分组的全部应用）
export function getSysGroupApps(groupId) {
  return request({
    url: `/online/management/admin/sysgroup/${groupId}/sysapp/list`,
    method: 'GET'
  })
}

// Switch the application version in the group
export function updGroupApkVersion(groupId, appFileId, data) {
  return request({
    url: `/online/management/admin/sysgroup/${groupId}/appfile/${appFileId}`, data,
    method: 'POST'
  })
}

// (管理员功能-分组中添加应用 2000-0011-0007)
export function addApk(groupId, data) {
  return request({
    url: `/online/management/admin/sysgroup/${groupId}/applications`, data,
    method: 'POST'
  })
}

// (管理员功能-分组中删除应用 2000-0011-0007)
export function delApk(groupId, data) {
  return request({
    url: `/online/management/admin/sysgroup/${groupId}/applications`, data,
    method: 'DELETE'
  })
}

// 分页查询分组的运营商列表
export function groupOperatorPage(groupId, params) {
  return request({
    url: `/online/management/admin/sysgroup/operator/${groupId}`, params,
    method: 'GET'
  })
}

// 添加分组的运营商
export function addgroupOperator(groupId, data) {
  return request({
    url: `/online/management/admin/sysgroup/operator/${groupId}`, data,
    method: 'POST'
  })
}

// 删除分组下的运营商
export function delgroupOperator(groupId, operatorId) {
  return request({
    url: `/online/management/admin/sysgroup/operator/${groupId}/${operatorId}`,
    method: 'DELETE'
  })
}

// 分页查询未绑定运营商列表
export function unBindOperatorPage(params) {
  return request({
    url: `/online/management/admin/sysgroup/operator/select`, params,
    method: 'GET'
  })
}
export function getAppVersionList(params) {
  return request({ url: '/online/management/admin/sysgroup/app/versionlist', params, method: 'GET'
  })
}
